<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>allocator_traits</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Chapter 1. Boost.Core">
<link rel="up" href="../index.html" title="Chapter 1. Boost.Core">
<link rel="prev" href="allocator_access.html" title="allocator_access">
<link rel="next" href="alloc_construct.html" title="alloc_construct">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="allocator_access.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="alloc_construct.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="core.allocator_traits"></a><a class="link" href="allocator_traits.html" title="allocator_traits">allocator_traits</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="allocator_traits.html#core.allocator_traits.overview">Overview</a></span></dt>
<dt><span class="section"><a href="allocator_traits.html#core.allocator_traits.reference">Reference</a></span></dt>
<dt><span class="section"><a href="allocator_traits.html#core.allocator_traits.notes">Notes</a></span></dt>
</dl></div>
<div class="simplesect">
<div class="titlepage"><div><div><h3 class="title">
<a name="idm1777"></a>Authors</h3></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
          Glen Fernandes
        </li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.allocator_traits.overview"></a><a class="link" href="allocator_traits.html#core.allocator_traits.overview" title="Overview">Overview</a>
</h3></div></div></div>
<p>
        This header &lt;boost/core/allocator_traits.hpp&gt; provides an implementation
        of the C++ standard library class template <code class="computeroutput"><span class="identifier">allocator_traits</span></code>
        based on the facilities in <a class="link" href="allocator_access.html" title="allocator_access">Allocator
        Access</a>. Users should still prefer the individual traits, but this
        utility exists to simplify migration.
      </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.allocator_traits.reference"></a><a class="link" href="allocator_traits.html#core.allocator_traits.reference" title="Reference">Reference</a>
</h3></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>

<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">A</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">allocator_traits</span> <span class="special">{</span>
    <span class="keyword">using</span> <span class="identifier">allocator_type</span> <span class="special">=</span> <span class="identifier">A</span><span class="special">;</span>

    <span class="keyword">using</span> <span class="identifier">value_type</span> <span class="special">=</span> <span class="identifier">allocator_value_type_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">pointer</span> <span class="special">=</span> <span class="identifier">allocator_pointer_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">const_pointer</span> <span class="special">=</span> <span class="identifier">allocator_const_pointer_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">void_pointer</span> <span class="special">=</span> <span class="identifier">allocator_void_pointer_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">const_pointer</span> <span class="special">=</span> <span class="identifier">allocator_const_void_pointer_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">difference_type</span> <span class="special">=</span> <span class="identifier">allocator_difference_type_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">size_type</span> <span class="special">=</span> <span class="identifier">allocator_size_type_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">propagate_on_container_copy_assignment</span> <span class="special">=</span>
        <span class="identifier">allocator_propagate_on_container_copy_assignment_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">propagate_on_container_move_assignment</span> <span class="special">=</span>
        <span class="identifier">allocator_propagate_on_container_move_assignment_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">propagate_on_container_swap</span> <span class="special">=</span>
        <span class="identifier">allocator_propagate_on_container_swap_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">using</span> <span class="identifier">is_always_equal</span> <span class="special">=</span> <span class="identifier">allocator_is_always_equal_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;;</span>

    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
    <span class="keyword">using</span> <span class="identifier">rebind_traits</span> <span class="special">=</span> <span class="identifier">allocator_traits</span><span class="special">&lt;</span><span class="identifier">allocator_rebind_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="special">&gt;;</span>

    <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">allocate</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">);</span>

    <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">allocate</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">const_void_pointer</span> <span class="identifier">h</span><span class="special">);</span>

    <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">deallocate</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">pointer</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">);</span>

    <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> <span class="identifier">Args</span><span class="special">&gt;</span>
    <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">construct</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">Args</span><span class="special">&amp;&amp;...</span> <span class="identifier">args</span><span class="special">);</span>

    <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">destroy</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">p</span><span class="special">);</span>

    <span class="keyword">static</span> <span class="identifier">size_type</span> <span class="identifier">max_size</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>

    <span class="keyword">static</span> <span class="identifier">A</span> <span class="identifier">select_on_container_copy_construction</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">);</span>
<span class="special">};</span>

<span class="special">}</span> <span class="comment">/* boost */</span>
</pre>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="core.allocator_traits.reference.static_member_functions"></a><a class="link" href="allocator_traits.html#core.allocator_traits.reference.static_member_functions" title="Static member functions">Static
        member functions</a>
</h4></div></div></div>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term"><code class="computeroutput"><span class="keyword">static</span> <span class="identifier">pointer</span>
            <span class="identifier">allocate</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">);</span></code></span></dt>
<dd><p>
                Equivalent to: <code class="computeroutput"><span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">allocator_allocate</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">n</span><span class="special">);</span></code>
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="keyword">static</span> <span class="identifier">pointer</span>
            <span class="identifier">allocate</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">size_type</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">const_void_pointer</span>
            <span class="identifier">h</span><span class="special">);</span></code></span></dt>
<dd><p>
                Equivalent to: <code class="computeroutput"><span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">allocator_allocate</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">h</span><span class="special">);</span></code>
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span>
            <span class="identifier">deallocate</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">pointer</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">size_type</span>
            <span class="identifier">n</span><span class="special">);</span></code></span></dt>
<dd><p>
                Equivalent to: <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">allocator_deallocate</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">h</span><span class="special">);</span></code>
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> <span class="identifier">Args</span><span class="special">&gt;</span> <span class="keyword">static</span>
            <span class="keyword">void</span> <span class="identifier">construct</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">Args</span><span class="special">&amp;&amp;...</span> <span class="identifier">args</span><span class="special">);</span></code></span></dt>
<dd><p>
                Equivalent to: <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">allocator_construct</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">p</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">forward</span><span class="special">&lt;</span><span class="identifier">Args</span><span class="special">&gt;(</span><span class="identifier">args</span><span class="special">)...);</span></code>
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span>
            <span class="identifier">destroy</span><span class="special">(</span><span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">T</span><span class="special">*</span> <span class="identifier">p</span><span class="special">);</span></code></span></dt>
<dd><p>
                Equivalent to: <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">allocator_destroy</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">p</span><span class="special">);</span></code>
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="keyword">static</span> <span class="identifier">size_type</span>
            <span class="identifier">max_size</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></code></span></dt>
<dd><p>
                Equivalent to: <code class="computeroutput"><span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">allocator_max_size</span><span class="special">(</span><span class="identifier">a</span><span class="special">);</span></code>
              </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="keyword">static</span> <span class="identifier">A</span>
            <span class="identifier">select_on_container_copy_construction</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">A</span><span class="special">&amp;</span> <span class="identifier">a</span><span class="special">);</span></code></span></dt>
<dd><p>
                Equivalent to: <code class="computeroutput"><span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">allocator_select_on_container_copy_construction</span><span class="special">(</span><span class="identifier">a</span><span class="special">);</span></code>
              </p></dd>
</dl>
</div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.allocator_traits.notes"></a><a class="link" href="allocator_traits.html#core.allocator_traits.notes" title="Notes">Notes</a>
</h3></div></div></div>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
            The member <code class="computeroutput"><span class="identifier">rebind_alloc</span></code>
            is not provided for parity with C++03 where it is unimplementable. Instead
            of <code class="computeroutput"><span class="identifier">allocator_traits</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;::</span><span class="identifier">rebind_alloc</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;</span></code>
            you can express the same with <code class="computeroutput"><span class="identifier">allocator_traits</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">&gt;::</span><span class="identifier">rebind_traits</span><span class="special">&lt;</span><span class="identifier">U</span><span class="special">&gt;::</span><span class="identifier">allocator_type</span></code>
            or more simply with <code class="computeroutput"><span class="identifier">allocator_rebind_t</span><span class="special">&lt;</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">U</span><span class="special">&gt;</span></code>.
          </li></ol></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2014 Peter Dimov<br>Copyright © 2014 Glen Fernandes<br>Copyright © 2014 Andrey Semashev<p>
        Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
        Software License, Version 1.0</a>.
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="allocator_access.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="alloc_construct.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
